class Admin::JoinRecordsController < Admin::BaseController
  before_action :set_join_record, only: [:show, :change_state]
  def index
    @join_records = JoinRecord.paginate(page: params[:page] || 1, per_page: params[:per_page] || 15).order("id desc")
  end

  def show
  end

  def change_state
    @join_record.update_attribute(:state, !@join_record.state)
    if @join_record.state
      flash[:notice] = "关闭成功"
    else
      flash[:notice] = "打开成功"
    end
    redirect_to admin_join_records_path
  end

  private

  def set_join_record
    @join_record = JoinRecord.find(params[:id])
  end
end
